package com.study.tiger.controller;

import com.study.tiger.service.EncryptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@Api(tags="加密解密")
public class EncryptController {

    @Autowired
    EncryptService encryptService;

    @GetMapping(value = "/getEncrypt",produces="application/json;charset=UTF-8")
    @ApiOperation(value = "ENCRYPT加密")
    public String getEncrypt(@ApiParam(value = "需要加密的字符串",required = true) @RequestParam("str") String str){
        return encryptService.getEncrypt(str);
    }

    @GetMapping(value = "/getDecrypt",produces="application/json;charset=UTF-8")
    @ApiOperation(value = "ENCRYPT解密")
    public String getDecrypt(@ApiParam(value = "需要解密的字符串",required = true) @RequestParam("str") String str){
        return encryptService.getDecrypt(str);
    }

}
